package com.google.code.roztocze358.server.businessobjects;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class CardsDeck implements Serializable {

	private static final long serialVersionUID = 1L;
	
	public static final int NUMBER_Of_CARDS = 52;
	
	private List<Card> deck = null;
	
	public CardsDeck() {
		super();
		deck = new ArrayList<Card>(NUMBER_Of_CARDS);
		for(Face face : Face.values()) {
			for(Suite suite : Suite.values()) {
				deck.add( new Card(suite,face) );
			}
		}
	}
	
	public static CardsDeck getNewDeck() {
		CardsDeck result = new CardsDeck();
		return result;
	}
	
	public Card getCard(int n) {
		if(n < 0 || n > NUMBER_Of_CARDS) throw new IllegalArgumentException("cards are numbered from 0 to " + (NUMBER_Of_CARDS-1));
		return deck.get(n);
	}

}
